package LeetCodeP;

/**
 * TOOD
 *
 * @author long
 * @date 2020-05-09 22:22
 */
public class Soluction242 {
    public static boolean isAnagram(String s, String t) {

        if (s.length() != t.length()) {
            return false;
        }
        int [] table=new int[26];
        for (int i=0;i<s.length();i++){
            table[s.charAt(i)-'a']++;


        }
        System.out.println("///");
        for (int i=0;i<t.length();i++){
            table[t.charAt(i)-'a']--;
            if (table[t.charAt(i)-'a']<0){
                return false;
            }
        }

        return  true;
    }

    public static void main(String[] args) {
        String s = "anagram";
        String t = "nagaram";
        boolean anagram = isAnagram(s, t);
        System.out.println(anagram);

    }
}
